package demo02

/**
 * @author xiaoZhao
 * @date 2022/6/20
 * @describe  字符串操作
 */
object Test03_String {
  def main(args: Array[String]): Unit = {
    val name: String = "lisi";
    val age: Int = 12
    println(age + "岁的" + name + "在吃饭")

    // * 用于将一个字符串复制多次拼接
    println(name * 3)

    printf("%d岁的%s在吃饭", age, name)
    println()

    println(s"${age}岁的${name}在吃饭")

    val num: Double = 2.26054
    println(s"this number is ${num}")
    // 格式化模板字符串
    println(f"this num is ${num}%2.2f")
    println(raw"this num is ${num}%2.2f")

    // 三引号表示字符串，保持多行字符串的原格式输出
    val sql =
      s"""
         |select *
         | from student
         | where name = ${name}
         | and
         | age > ${age}
         |""".stripMargin
    println(sql)
  }
}
